import { request } from './request.js'

//获取轮播图数据
export function getBanner(type) {
    return request({
        url: 'banner',
        //配置query参数
        params: {
            type
        }
    })
}

//获取推荐歌单数据
export function getRecommendMusicList(limit) {
    return request({
        url: 'personalized',
        params: {
            limit,
        }
    })
}

//获取独家放送数据
export function getBroadcastList() {
    return request({
        url: 'personalized/privatecontent',
    })
}

//获取最新音乐
export function getNewSongList() {
    return request({
        url: 'personalized/newsong',
    })
}

//获取歌单详情
export function getMusicListDetail(id) {
    return request({
        url: '/playlist/detail',
        params: {
            id,
        }
    })
}

//歌单详情数据太深，封装个类
export class MusicListDetailInfo {
    constructor(data) {
        //歌单信息
        this.coverImgUrl = data.coverImgUrl
        this.title = data.name
        this.authorHeadPic = data.creator.avatarUrl
        this.authorName = data.creator.nickname
        this.createTime = data.createTime
        this.tags = data.tags
        this.desc = data.description
        this.subscribeCount = data.subscribedCount
        this.shareCount = data.shareCount
        this.trackCount = data.trackCount
        this.playCount = data.playCount
        this.commentCount = data.commentCount

        //每首歌的信息
        this.item = data.tracks
    }
}

//获取歌曲详情
export function getSongDetail(idsStr) {
    return request({
        url: '/song/detail',
        params: {
            ids: idsStr,
        }
    })
}

//获取歌单评论信息
export function getSongListComment(id, offset) {
    return request({
        url: '/comment/playlist',
        params: {
            id,
            offset,
            limit: 10
        }
    })
}

//获取歌曲评论信息
export function getSongComment(id, offset) {
    return request({
        url: '/comment/music',
        params: {
            id,
            offset,
            limit: 10
        }
    })
}